package com.srcptit.tranning.toannt.btvn1;

public class Bai_8 {
	 public static void main(String[] args) {
	        for(long i = 1000000; i <= 9999999; i++){
	            if(test(i)) System.out.println(i);
	        }
	    }
	 public static boolean test(long n){
		 if(Nguyento(n))if(csngto(n))if(tang(n))return true;
		return false;
	 }
	    public static boolean Nguyento(long n){
	        if(n < 2) return false;
	        for(int i = 2; i <= Math.sqrt(n); i++) if(n % i == 0 ) return false;
	        return true;
	    }
	    public static boolean csngto(long n){
	        while(n > 0){
	            long i =  n % 10;
	            if(i == 0 || i == 1|| i == 4|| i == 6|| i == 8|| i == 9){
	                return false;
	            }
	            n = n / 10;
	        }
	        return true;
	    }
	    public static boolean tang(long n){
	        while(n > 10){
	            long i = n % 10;
	            long j = (n / 10) % 10;
	            if(i < j) return false;
	            n = n / 10;
	        }
	        return true;
	    }
}
